/********************************************************/
/*	Copyright (C) 2012 Gong Li Bin			*/
/*	Project:	MapReduce			*/
/*	Author:		gong_libin			*/
/*	Date:		2013_05_14			*/
/*	File:		MrReportTest.cpp		*/
/********************************************************/

#include "MrPro.h"
#include "MrMulti.h"

int main(int argc, char* argv[])
{
	CMrPro CPro;
	CMrMulti CRecv;
	int iLength = 0;
	UINT uiCount = 1;
	MRPROKV_S stKv[MR_BUFFER];
	UCHAR uszRecv[MR_ETHERNET - MR_MACIPUDP] = { 0 };

	if (MR_SUCCESS == CRecv.MrNetInitRecv((char*)"238.2.10.68", (char*)"29880")) {
		while ((iLength = CRecv.MrNetRecv(uszRecv, MR_ETHERNET - MR_MACIPUDP)) > 0) {
			MR_PRINT("===[%04d]===\n", uiCount ++);
			/* head */
			CPro.MrProParse(uszRecv, iLength);
			CPro.MrProDisplay();
			/* body */
			MrProKvInput(stKv, CPro.MrProGetTotal(), CPro.MrProGetBody(), CPro.MrProGetLength());
			MrProKvDisplay(stKv, CPro.MrProGetTotal());
			/* reset */
			memset(uszRecv, '\0',  MR_ETHERNET - MR_MACIPUDP);
			memset(stKv, '\0', sizeof(stKv));
		}
		CRecv.MrNetClose();
	}

	return MR_SUCCESS;
}
